package com.yykj.hospital.server.converter;

import com.yykj.common.enums.HospitalAdminType;
import com.yykj.hospital.client.dto.HospitalAdminListDTO;
import com.yykj.hospital.server.model.entity.HospitalAdmin;
import org.springframework.beans.BeanUtils;

import java.util.List;
import java.util.stream.Collectors;

public class HospitalAdminListDTOConverter {
    public static HospitalAdminListDTO convert(HospitalAdmin hospitalAdmin){
        HospitalAdminListDTO dto = new HospitalAdminListDTO();
        BeanUtils.copyProperties(hospitalAdmin,dto);
        if(HospitalAdminType.admin.equals(hospitalAdmin.getType())){
            dto.setRoleName("系统管理员");
        }
        return dto;
    }

    public static List<HospitalAdminListDTO> convert(List<HospitalAdmin> list){
        return list.stream().map(HospitalAdminListDTOConverter::convert).collect(Collectors.toList());
    }
}
